﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace PersonInfo
{
    class ValidationUtils
    {
        public static bool IsNameValid(string name)
        {
            string pattern = @"\A[A-Z]{1}[a-z]+\Z";
            bool res = Regex.IsMatch(name, pattern);
            return res;
        }

        public static bool IsSSNValid(string ssn)
        {
            string pattern = @"\A[0-9]{9}\Z";
            bool res = Regex.IsMatch(ssn, pattern);
            return res;
        }

        public static bool IsEmailValid(string email)
        {
            string pattern = @"\A[a-zA-Z0-9]+[a-zA-Z0-9\._]*@[a-zA-Z0-9]+.([a-zA-Z0-9]+\.)*[a-zA-Z]{2,4}\Z";
            bool res = Regex.IsMatch(email, pattern);
            return res;
        }

        public static bool IsPhoneValid(string phone)
        {
            string pattern = @"\A[0-9]+[0-9\s]*\Z";
            bool res = Regex.IsMatch(phone, pattern);
            return res;
        }
    }
}
